Skip to content

fix(dgw): fix adaptive frame skipping during EOF waits in session shadowing#1678

Merged
irvingouj@Devolutions (irvingoujAtDevolution) merged 5 commits intomasterfrom
fix-adaptive-frame-skip-eof-ratio
Mar 2, 2026
Merged

fix(dgw): fix adaptive frame skipping during EOF waits in session shadowing#1678
irvingouj@Devolutions (irvingoujAtDevolution) merged 5 commits intomasterfrom
fix-adaptive-frame-skip-eof-ratio

Conversation

@irvingoujAtDevolution
Copy link
Contributor

@irvingoujAtDevolution irvingouj@Devolutions (irvingoujAtDevolution) commented Feb 13, 2026

Fixes video playback freezing permanently during live session shadowing. After brief pauses in the recording stream (e.g., during network hiccups or slow file writes), the shadow player would stop rendering new frames entirely, requiring a session restart.

With this fix, shadow sessions now recover gracefully from temporary recording pauses, maintaining smooth video playback throughout the session.

Issue: DGW-341

@github-actions
Copy link

Let maintainers know that an action is required on their side

  • Add the label release-required Please cut a new release (Devolutions Gateway, Devolutions Agent, Jetsocat, PowerShell module) when you request a maintainer to cut a new release (Devolutions Gateway, Devolutions Agent, Jetsocat, PowerShell module)

  • Add the label release-blocker Follow-up is required before cutting a new release if a follow-up is required before cutting a new release

  • Add the label publish-required Please publish libraries (`Devolutions.Gateway.Utils`, OpenAPI clients, etc) when you request a maintainer to publish libraries (Devolutions.Gateway.Utils, OpenAPI clients, etc.)

  • Add the label publish-blocker Follow-up is required before publishing libraries if a follow-up is required before publishing libraries

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes a critical bug in session shadowing where adaptive frame skipping would permanently stall video streaming after EOF retry waits. The issue occurred because the realtime ratio calculation (used to decide whether to skip frames) included idle time spent waiting for file growth, causing the ratio to drop far below the 1.0 threshold and triggering perpetual decode-only mode.

Changes:

  • Modified the realtime ratio calculation to track only active processing time, excluding EOF wait periods
  • Added a 3-second timeout to EOF waits to prevent indefinite stalls
  • Increased MAX_RETRY_COUNT from 3 to 25 to accommodate the new timeout-based retry strategy

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
crates/video-streamer/src/streamer/tag_writers.rs Added processing_time tracking to measure only active processing (excluding idle waits), updated current_realtime_ratio to use processing_time instead of wall time, added Duration import
crates/video-streamer/src/streamer/mod.rs Added 3-second timeout to EOF waits, increased MAX_RETRY_COUNT from 3 to 25 to accommodate timeout-based retries

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@CBenoit
Copy link
Member

Copy link
Member

@CBenoit Benoît Cortier (CBenoit) left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I’m good with the changes, so I’m approving now. Feel free to merge when you are satisfied.

Before merging, make sure you follow these instructions for the PR / commit: https://github.com/Devolutions/devolutions-gateway/blob/b955082ef7f98c94ea24f37b83528b4e72a26f37/AGENTS.md#pr-body

Especially, the PR title/body:

  • Should include a user-oriented description (what users gain/notice)
  • Can include technical context for developers
  • Avoid internal implementation details
  • Focus on impact and benefits
  • This text appears in the changelog for feat/fix/perf

@irvingoujAtDevolution irvingouj@Devolutions (irvingoujAtDevolution) force-pushed the fix-adaptive-frame-skip-eof-ratio branch 2 times, most recently from 0ea587a to b15648e Compare March 2, 2026 15:30
@irvingoujAtDevolution
Copy link
Contributor Author

Implementation Details

Root cause: The adaptive frame skip ratio (media_time / wall_time) was corrupted by idle time spent waiting for the recording file to grow during EOF retries. A 20-second EOF wait produced a ratio of ~0.006, far below the 1.0 threshold, causing all subsequent frames to be decode-only with no encoded output reaching the player.

Changes:

  • Changed ratio calculation to use accumulated active processing time (media_time / processing_time) instead of total wall time, excluding idle waits
  • Added 3-second timeout to EOF waits to limit maximum stall duration per retry
  • Increased MAX_RETRY_COUNT from 3 to 25 to accommodate the timeout-based retry strategy (worst case: 75s total, but downstream components enforce stricter overall timeouts)

…dowing

Fixes playback failures in session shadowing where adaptive frame skipping
permanently stalls video streaming after EOF retry waits.

The ratio used for adaptive frame skip decisions (media_time / wall_time)
was corrupted by time spent waiting for the recording file to grow during
EOF retries. A 20-second EOF wait would result in a ratio of ~0.006, far
below the 1.0 threshold, causing all subsequent frames to be decode-only
with no encoded output reaching the player.

The fix changes the ratio to only measure active processing time
(media_time / accumulated_processing_time) instead of total wall time,
excluding idle waits. Additionally, EOF waits now time out after 3 seconds
to limit the maximum stall duration.

Issue: DGW-341
Lower EOF timeout log from info! to trace!, add rationale comment
for MAX_RETRY_COUNT, and document current_realtime_ratio() intent.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@irvingoujAtDevolution irvingouj@Devolutions (irvingoujAtDevolution) merged commit a1566fd into master Mar 2, 2026
40 checks passed
@irvingoujAtDevolution irvingouj@Devolutions (irvingoujAtDevolution) deleted the fix-adaptive-frame-skip-eof-ratio branch March 2, 2026 19:44
@irvingoujAtDevolution
Copy link
Contributor Author

irvingouj@Devolutions (irvingouj@Devolutions (@irvingoujAtDevolution)) Is it ready?

Sorry, took a while, it's ready now

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

4 participants